package org.medusa.style;

public abstract class MultiResult<ValueType> {

	private Error err = null;
	private ValueType val = null;

	public MultiResult() {

	}

	protected abstract ValueType create_null_value();

	public Error Error() {
		return this.err;
	}

	public void Error(String errinfo) {
		if (errinfo == null)
			this.err = null;
		else
			this.err = new Error(errinfo);
	}

	/*
	 * public void Error(Error err){ this.err = err; }
	 */

	public ValueType Value() {
		if (this.val == null)
			this.val = this.create_null_value();
		return this.val;
	}

	public void Value(ValueType val) {
		this.val = val;
	}

	public void Set(String errinfo, ValueType val) {
		this.err = new Error(errinfo);
		this.val = val;
		if (this.val == null)
			this.val = this.create_null_value();
	}

	public String ErrorMessage() {
		if (err != null)
			return this.err.getMessage();
		else
			return "non";
	}
}
